const getSelectedText = () => window.getSelection().toString();

getSelectedText(); // 'Lorem ipsum'